package card

import "zinx_websokect_poker/zinx_app/poker_game/protocol"
/**

	相同牌型的比牌方法，
	若是第一幅牌型大返回true
	反之则返回false
 */


func PkOnePair(str1, str2 protocol.OnePair) bool{

	if str1.PairPoint > str2.PairPoint {
		return true
	}
	if str1.PairPoint < str2.PairPoint {
		return false
	}

	//对子相等，比较单张,一次比对大中小三张单张
	if str1.PairPoint == str2.PairPoint {
		if str1.Big > str2.Big {
			return true
		}
		if str1.Big < str2.Big {
			return false
		}
		if str1.Big == str2.Big {
			if str1.Middle > str2.Middle {
				return true
			}
			if str1.Middle < str2.Middle {
				return false
			}
			if str1.Middle == str2.Middle {
				if str1.Small > str2.Small {
					return true
				}
				if str1.Small < str2.Small {
					return false
				}
			}
		}
	}

	return true
}

func PkHighCard(str1, str2 protocol.Flush) bool {
	cards1 := str1.Cards
	cards2 := str2.Cards

	if cards1[4] > cards2[4] {
		return true
	}

	if cards1[4] < cards2[4] {
		return false
	}

	if cards1[4] == cards2[4] {
		if cards1[3] > cards2[3] {
			return true
		}
		if cards1[3] < cards2[3] {
			return false
		}
		if cards1[3] == cards2[3]{
			if cards1[2] > cards2[2] {
				return true
			}
			if cards1[2] < cards2[2] {
				return false
			}
			if cards1[2] == cards2[2]{
				if cards1[1] > cards2[1] {
					return true
				}
				if cards1[1] < cards2[1] {
					return false
				}
				if cards1[1] == cards2[1]{
					if cards1[0] > cards2[0] {
						return true
					}
					if cards1[0] < cards2[0] {
						return false
					}
				}
			}
		}
	}

	return true
}

func PkTwoPair(str1, str2 protocol.TwoPair) bool{

	if str1.BigPoint > str2.BigPoint {
		return true
	}
	if str1.BigPoint < str2.BigPoint {
		return false
	}
	if str1.BigPoint == str2.BigPoint {
		if str1.SmallPoint > str2.SmallPoint {
			return true
		}
		if str1.SmallPoint < str2.SmallPoint {
			return false
		}
		if str1.SmallPoint == str2.SmallPoint {
			if str1.SingePoint > str2.SingePoint {
				return true
			}
			if str1.SingePoint < str2.SingePoint {
				return false
			}
		}
	}

	return true
}

func PkThree(str1, str2 protocol.Three) bool{

	if str1.ThreePoint > str2.ThreePoint {
		return true
	}
	if str1.ThreePoint < str2.ThreePoint {
		return false
	}
	if str1.ThreePoint == str2.ThreePoint {
		if str1.BigPoint > str2.BigPoint {
			return true
		}
		if str1.BigPoint < str2.BigPoint {
			return false
		}
		if str1.BigPoint == str2.BigPoint {
			if str1.SmallPoint > str2.SmallPoint {
				return true
			}
			if str1.SmallPoint < str2.SmallPoint {
				return false
			}
		}
	}

	return true
}

func PkFullHouse(str1, str2 protocol.FullHouse) bool{

	if str1.ThreePoint > str2.ThreePoint {
		return true
	}
	if str1.ThreePoint < str2.ThreePoint {
		return false
	}
	if str1.ThreePoint == str2.ThreePoint {
		if str1.TwoPoint > str2.TwoPoint {
			return true
		}
		if str1.TwoPoint < str2.TwoPoint {
			return false
		}
	}

	return true
}

func PkFour(str1, str2 protocol.Four) bool{
	if str1.Fpoint > str2.Fpoint {
		return true
	}
	if str1.Fpoint < str2.Fpoint {
		return false
	}
	if str1.Fpoint == str2.Fpoint {
		if str1.Opoint > str2.Opoint {
			return true
		}
		if str1.Opoint < str2.Opoint {
			return false
		}
	}

	return true
}

func PkStraight(str1, str2 protocol.Straight) bool{

	if str1.Point > str2.Point {
		return true
	}else {
		return false
	}

}
